from wechat.webot import *

base_url = "http://127.0.0.1:8989/api"

wx_context = get_wx_context(base_url)

"""
需要先进入libs目录执行: .\inject_tool.exe start 8989 --my_port=9000
登录微信后再运行该脚本
"""


def handleMessageFun(wx_message: WxMessage):
    # 一定要加上这句，不然会陷入死循环
    if wx_message.is_self_msg != 1:
        send_msg(base_url, wx_message.wx_id, wx_message.content)
        # send_img(base_url, wx_message.wx_id, r".\a.jpg")
        # send_file(base_url, wx_message.wx_id,r"./aaa.txt")


WeMessageListener(handleMessageFun, host='127.0.0.1', port=9000)
